<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //  支付表
        // 需要考虑 是否拆分支付详情
        // 需要考虑 是否不同类型 走不同的支付表
        Schema::create('order_pay_details', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户');
            $table->string('trip_id')->comment('行程id');
            $table->unsignedTinyInteger('trip_type')->comment('行程类型。回调更新订单判断');
            $table->string('pay_sn')->comment('支付单号');
            $table->string('order_sn')->comment('订单编号');
            $table->unsignedDecimal('order_amount', 10, 2)->comment('订单金额');
            $table->unsignedTinyInteger('sharing_flag')->default(0)->comment('分账标识,根据订单服务商分配的账户分账此阶段或许没有');
            $table->unsignedTinyInteger('separate')->default(0)->comment('独立支付 1 非独立支付 0 ，火车中转含飞机票 机票可独立支付');
            $table->string('business_type')->default(10)->comment('业务类型 10 下单, 11 改签 ,20  抢票 ,21 编辑抢票任务');
            $table->timestamps();
            $table->unique(['order_sn', 'pay_sn'], 'unique_ordersn_pay_sn');
            $table->index(['order_sn', 'user_id'], 'index_order_user');
            $table->index(['pay_sn', 'order_sn'], 'index_pay_order');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_pay_details');
    }
};
